// Used to store that is shared between the functions/chapters of a mission.

//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "management\fn_setMissionVar.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_key","_value","_instance_id","_result","_variables","_name"];
DEFAULT_PARAM(_instance_id,0,TMF_SERVER_INSTANCE_ID);
DEFAULT_PARAM(_key,1,"");
DEFAULT_PARAM(_value,2,nil);

if (_key != "") then {
	_name = format [QGVAR(MISSION_VARIABLES_%1),_instance_id];
	_variables = [];
	if (isNil _name) then {
		_variables = (call FFUNC(hashEmpty));
	} else {
		_variables = missionNameSpace getVariable _name;
	};
	_variables = [_variables,_key,VALORNIL(_value)] call FFUNC(hashSet);
	missionNameSpace setVariable [_name,_variables];
	// _variables = OGETVAR(GVAR(mission_variables),_instance_id,(call FFUNC(hashEmpty)));
	// _variables = [_variables,_key,VALORNIL(_value)] call FFUNC(hashSet);
	// OSETVAR(GVAR(mission_variables),_instance_id,_variables);
};
TRACE("End");
TMFPROFILERSTOP;
